/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.alvin.tools.ui;

import craky.componentc.CRootPaneUI;
import craky.componentc.JCButton;
import craky.componentc.JCFrame;
import craky.componentc.JCMenu;
import craky.componentc.JCTabbedPane;
import java.awt.BorderLayout;
import java.awt.Insets;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JToolBar;

/**
 *
 * @author tangzhichao
 */
public class ToolsMainFrame extends JCFrame {

    /**
     * Creates new form ToolsMainFrame
     */
    public ToolsMainFrame() {
        initComponents();
        setSize(1024, 768);
        setTitle("工具管理");
        setBackgroundImage(new ImageIcon(getClass().getResource("/publicresource/bg.jpg")).getImage());
        setImageDisplayMode(CRootPaneUI.ImageDisplayMode.SCALED);
        setImageAlpha(.5f);
        initUI();
        setLocationRelativeTo(null);
        setExtendedState(MAXIMIZED_BOTH);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void initUI() {
        JPanel contentPane = new JPanel() {
            @Override
            public Insets getInsets() {
                return new Insets(0, 5, 5, 5);
            }
        };
        contentPane.setOpaque(false);
        this.setContentPane(contentPane);
        contentPane.setLayout(new BorderLayout(5, 0));
        initMenuBar(contentPane);
        initContent(contentPane);

    }

    private void initMenuBar(JComponent contentPane) {
        JMenuBar menubar = new JMenuBar();
        menubar.add(createFileMenu());
        menubar.add(createHelpMenu());
        contentPane.add(menubar, BorderLayout.NORTH);
    }

    private void initContent(JComponent contentPane) {
        JPanel mainPanel = new JPanel();
        mainPanel.setOpaque(false);
        mainPanel.setLayout(new BorderLayout(5, 0));
        contentPane.add(mainPanel, BorderLayout.CENTER);
        //
        JToolBar toolbar = new JToolBar();
        mainPanel.add(toolbar, BorderLayout.NORTH);
        toolbar.add(new JCButton("Test"));
        //
        JCTabbedPane tabPane = new JCTabbedPane();
        tabPane.addTab("Home", new JPanel());
        mainPanel.add(tabPane, BorderLayout.CENTER);
    }

    private JMenu createFileMenu() {
        JCMenu menu = new JCMenu("File");
        return menu;
    }

    private JMenu createHelpMenu() {
        JCMenu menu = new JCMenu("Help");
        return menu;
    }

    public static void main(String[] args) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ToolsMainFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
